package com.vito.dcs.sys.material.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.vito.base.factory.IDFactory;
import com.vito.base.model.DataGrid;
import com.vito.dcs.sys.material.dao.SysMaterialMapper;
import com.vito.dcs.sys.material.model.SysMaterialModel;
import com.vito.dcs.sys.material.service.SysMaterialService;

/**
 * 材料类型
 * @author lyhao
 *
 */
@Service
public class SysMaterialServiceImpl implements SysMaterialService {
	
	@Autowired
	private SysMaterialMapper sysMaterialMapper;
	
	@Override
	public void saveSysMaterial(SysMaterialModel sysMaterialModel){
		sysMaterialModel.setId(IDFactory.getIDFactory().getIdInc()+"");          
		sysMaterialMapper.saveSysMaterial(sysMaterialModel);
	}
	@Override
	public DataGrid<SysMaterialModel> querySysMaterialByPage(SysMaterialModel sysMaterialModel){
		DataGrid<SysMaterialModel> dg = new DataGrid<SysMaterialModel>();
		dg.setRows(sysMaterialMapper.querySysMaterialByPage(sysMaterialModel));
		dg.setTotal(sysMaterialModel.getTotal());
		return dg;
	}
	@Override
	public SysMaterialModel querySysMaterial(SysMaterialModel sysMaterialModel){
		return sysMaterialMapper.querySysMaterial(sysMaterialModel);
	}
	@Override
	public SysMaterialModel updateSysMaterial(SysMaterialModel sysMaterialModel){
		if(sysMaterialMapper.updateSysMaterial(sysMaterialModel)>0){
			return sysMaterialModel;
		}else{
			return null;
		}
	}
	
	@Override
	public Integer deleteSysMaterial(SysMaterialModel sysMaterialModel){
		return sysMaterialMapper.deleteSysMaterial(sysMaterialModel);
	}
	@Override
	public List<SysMaterialModel> queryMaterialListByLayerId(String layerId) {
		return sysMaterialMapper.findMaterialList(layerId);
	}

}